<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use User\Api\UserApi;

/**
 * 用户控制器
 * 包括用户中心，用户登录及注册
 */
class MailerController extends HomeController {
	public function send(){
		$verify = I('post.verify');
		if(!check_verify($verify)){
			$this->JlzAjaxReturn(-1,'验证码错误');
		}
		vendor('PHPMailer.class#smtp');
		vendor('PHPMailer.class#phpmailer');    //注意这里的大小写哦，不然会出现找不到类，PHPMailer是文件夹名字，class#phpmailer就代表class.phpmailer.php文件名

		$name = I('post.name','空');
		$tel = I('post.tel','空');
		$info = I('post.info','空');
		$body = "内容：{$info}    姓名：{$name} 电话：{$tel}";
		$title = I('post.title','pos收银');

		$mail = new \PHPMailer();
		// 装配邮件服务器
		$mail->IsSMTP();
		$mail->Host = 'smtp.163.com';  //这里的参数解释见下面的配置信息注释
		$mail->SMTPAuth = TRUE;
		$mail->Username = '13675731925@163.com';
		$mail->Password = 'shouxingru123';
		$mail->SMTPSecure = C('MAIL_SECURE');
		$mail->CharSet = 'utf-8';
		$mail->Port = 25;
		// 装配邮件头信息
		$mail->From = '13675731925@163.com';
		$mail->AddAddress('506895527@qq.com');
		$mail->FromName = '锦蓝钻收银官网';
		$mail->IsHTML(true);
		// 装配邮件正文信息
		$mail->Subject = $title;
		$mail->Body = $body;
		// 发送邮件
		if (!$mail->Send()) {
			$this->JlzAjaxReturn(-1,'发送失败'.$mail->ErrorInfo);
		} else {
			M('Mailer')->add(array('name' => $name,'tel' => $tel,'info' => $info,'create_time' => time()));
			$this->JlzAjaxReturn(1,'发送成功！');
		}
	}

	public function verify(){
		$verify = new \Think\Verify();
		$verify->entry(1);
	}
}
